<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <script src="../org/angular.min.js"></script>
</head>
<body>

<div ng-app="hd" ng-controller="ctrl">

{{order_data}}<br/>

<button ng-click="myOrderBy()">控制器中使用过滤器</button>
</div>


<script>
    var m = angular.module('hd', []);
    m.controller('ctrl', ['$scope', '$filter', function ($scope, $filter) {

        $scope.order_data = [
            {id:1, click:100, title: '后盾人1'},
            {id:2, click:200, title: '后盾人2'},
            {id:3, click:300, title: '后盾人3'},
        ];

        $scope.myOrderBy = function () {
            /*filter的参数是要使用的过滤器，后面括号里面是过滤器的参数*/
            $scope.order_data = $filter('orderBy')($scope.order_data, 'id', true);
        }

    }]);
</script>


</body>
</html>

